package bishi.didi;

/**
 * @author: Tangxz
 * @email: 1171702529@qq.com
 * @cate: 2021/10/19 18:58
 */
public class one {
    class Node {
        int val;
        Node next;

        Node(int val) {
            this.val = val;
        }
    }

    public boolean ww(Node head) {
        int n = 0;
        Node tem = head;
        while (tem != null) {
            n++;
            tem = tem.next;
        }
        Node left, pre = null, next;
        left = head;
        int num = n / 2;
        while (num > 0) {
            num++;
            next = left.next;
            left.next = pre;
            pre = left;
            left = next;
        }
        if (n % 2 == 1) left = left.next;
        while (left != null && pre != null) {
            if (left.val != pre.val) return false;
            left = left.next;
            pre = pre.next;
        }
        return true;

    }
}
